<div class="layuimini-container layuimini-page-anim">
    <div class="layuimini-main">

        <fieldset class="table-search-fieldset">
            <legend>卡密生成</legend>
            <div style="margin: 10px 10px 10px 10px">
                <form class="layui-form layui-form-pane" action="">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">生成数量</label>
                            <div class="layui-input-inline">
                                <input type="text" name="num" autocomplete="off" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label">生成类型</label>
                            <div class="layui-input-inline">
                                <select name="type">
                                    <option value="1" selected="">余额</option>
                                    <option value="2">时间</option>
                                </select>
                            </div>
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label">卡密面值</label>
                            <div class="layui-input-inline">
                                <input type="text" name="value" autocomplete="off" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-inline">
                            <button type="button" class="layui-btn layui-btn-primary" lay-submit
                                lay-filter="data-search-btn"> 添加</button>
                        </div>
                    </div>
                </form>
            </div>
        </fieldset>
        <style>
            .layui-table-tool {
                background: #fff;
            }
        </style>
        <script type="text/html" id="toolbarDemo">

            <div class="layui-btn-container">
                <button class="layui-btn layui-btn-sm data-add-btn" lay-event="add"> 卡密列表 </button>
                <!-- <button class="layui-btn layui-btn-sm layui-btn-danger data-delete-btn" lay-event="delete"> 删除用户 </button> -->
            </div>
        </script>

        <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>

        <script type="text/html" id="currentTableBar">
        <a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" lay-event="delete">删除</a>
        </script>

        <script type="text/html" id="stateTemp">
            <button class="layui-btn layui-btn-xs">未使用</button>
        </script>

    </div>
</div>

<script>
    layui.use(['form', 'table', 'miniPage', 'lycms', 'element'], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table,
            miniPage = layui.miniPage,
            lycms = layui.lycms;
        form.render();


        // 监听添加操作
        form.on('submit(data-search-btn)', function (data) {
            table.render({
                elem: '#currentTableId',
                url: '/ask/action/system/kami/add',
                where: data.field,
                method: "post",
                toolbar: '#toolbarDemo',
                defaultToolbar: ['filter', 'exports', 'print'],
                cols: [[
                    { field: "id", title: '序号', width: 80 },
                    { field: 'content', title: '卡密内容' },
                    { field: 'value', title: '卡密面值', sort: true, width: 100, align: "center" },
                    {
                        field: 'state', templet: '#stateTemp', width: 120, title: '使用状态', align: "center"
                    },
                    { field: 'time', width: 220, title: '添加时间', sort: true, align: "center" },
                    { title: '操作', width: 90, minWidth: 50, templet: '#currentTableBar', fixed: "right", align: "center" }
                ]],
            });
            return false;
        });

    });
</script>